package licode.unisop.types.dp;

import org.springframework.util.Assert;

/**
 * 菜单类型
 */
public class MenuType {

    public static final MenuType DIR = new MenuType(1);
    public static final MenuType MENU = new MenuType(2);

    private final int type;

    private MenuType(int type) {
        this.type = type;
    }

    public static MenuType build(int type) {
        Assert.isTrue(type == 1 || 2 == type,
                "菜单类型取值1或2，当前：" + type);
        if (DIR.type == type) {
            return MenuType.DIR;
        }
        return MenuType.MENU;
    }

    public boolean isMenu() {
        return (2 == type);
    }

    public boolean isDirectory() {
        return (1 == type);
    }

    public int getType() {
        return type;
    }

    @Override
    public String toString() {
        return type + "";
    }
}
